#include <cstdlib>
#include <iostream>
#include <fstream>
#include <windows.h>

using namespace std;

extern void UserWrite();
extern void PwrWrite();
extern int Pass;
extern bool Battle();
extern void DrawCamp();
extern void DrawTaishan();
extern void DrawShaolin();
extern void DrawHuangshan();
extern void DrawXianyang();
extern void DrawYan();
extern void DrawWudang();
extern void DrawFriendship();
extern void DrawFaith();
extern void DrawDragon();

extern int DeptStat[8];
extern int DeptPwr[10];
extern string Name;
extern bool Muye;
extern bool temp1;
extern bool temp2;
extern bool temp3;
extern bool temp4;
extern bool temp5;

string OfficeChoice;

bool event=false;


void AutoSave()
{
     UserWrite();
     PwrWrite();
     cout << "Your game is been autosaved!\n";
}

void GetEvent()
{
     cout << "No Game event available at this point.\n";
}


void TimeMachine()
{
     system("cls");
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     cout << "Ten years ago" << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     system("pause");
     system("cls");
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause"); 
     system("cls");
     cout << "Muye: Shixiong, are you here?" << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause"); 
     system("cls");
     cout << Name << ": " << "Yes, I am right here." << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause"); 
     system("cls");
     cout << "Muye: My dad said that when I grow up he will" << endl;
     cout << "      marry me to a rich man. And not letting you to see me." << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause"); 
     system("cls");
     cout << Name << ": " << "Why he do that? " << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause"); 
     system("cls");
     cout << "Muye: I have no idea, I don't want to grow up." << endl;
     cout << "      I want to stay with my Shixiong. I love to " << endl;
     cout << "      run in the wheat field with you." << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause");
     system("cls"); 
     cout << Name << ": " << "Trust me, I will protect you." << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause");
     system("cls"); 
     cout << "Muye: You will?" << endl;
     for(int x(0); x<12;x++)
     cout << endl;
     cout << "                    ";
     system("pause");
     system("cls"); 
     cout << Name << ": " << "I promise." << endl;
     system("pause"); 
     
}

void GetMap()
{
     switch(DeptStat[0])
     {
                      case 0:
                           DrawCamp();;
                           break;
                      case 1:
                           DrawTaishan();
                           break;
                      case 2:
                           DrawShaolin();
                           break;
                      case 3:
                           DrawHuangshan();
                           break;
                      case 4:
                           DrawXianyang();
                           break;
                      case 5:
                           DrawYan();
                           break;
                      case 6:
                           DrawWudang();
                           break;
                      case 7:
                           DrawFriendship();
                           break;
                      case 8:
                           DrawFaith();
                           break;
                      case 9:
                           DrawDragon();
                           break;
                      default:
                              cout << "Unidentified Error!" << endl;
                              exit(1);
     }
}

void GoOffice(int Senario)
{
     //cout << "Senario: " << Senario << endl;
     switch(Senario)
     {
                    case 0:
                         select:
                         cout << "Sorry, there is nobody in the office." << endl;
                         cout << "You can choose QUIT (0) to exit" << endl;
                         cout << "Type SEARCH to search items in the office" << endl;
                         cout << "\n(STRING)>>>";
                         cin >> OfficeChoice;
                         if(OfficeChoice == "SEARCH")
                         {
                                   int num;
                                   num = rand() % 10 + 1;
                                   cout << "You find " << num << " items." << endl;
                                   DeptPwr[2] += num;
                         }
                         else if (OfficeChoice != "QUIT")
                         {
                              cout << "Wrong selection!" << endl;
                              goto select;
                         }
                         
                         break;
                    case 1:
                         cout << "Shifu: " << Name << ", come and sit" << endl;
                         system("pause");
                         cout << Name << ": " << "how can I find my friends?" << endl;
                         system("pause");
                         cout << "Shifu: These years, the Nian killed many of my students." << endl;
                         cout << "This quest is hard, you need to be careful." << endl;
                         system("pause");
                         cout << Name << ": " << "Can you help me?" << endl;
                         system("pause");
                         cout << "Shifu: take this, this will help you." << endl; 
                         system("color 0a");
                         system("cls");
                         for(int x(0);x<12;x++)
                         cout << endl;
                         cout << "                      Item Aquired!" << endl;
                         system("pause");
                         system("color 07");
                         DeptPwr[5] += 100;
                         break;
                    case 2:
                         cout << "Muye: " << Name << " is that you?" << endl;
                         system("pause");
                         cout << Name << ": " << "Yes, it is me." << endl;
                         cout << Name << ": " << "What are you doing here?" << endl;
                         cout << "Muye: I have no choice my dad is taken by Nian" << endl;
                         cout << "      and my mother died while saving him." << endl;
                         cout << "-----------------------------------------------" << endl;
                         cout << "(0)Such a brave women." << endl;
                         cout << "(1)Why she do that?" << endl;
                         cout << "(SELECT)>>>";
                         cin >> temp1;
                         cout << "Muye: My mother didn't die, she overreached her" << endl;
                         cout << "      power. So she is covered with Crystal." << endl;
                         cout << "Muye: I miss her, (Crying....) I really miss her" << endl;
                         cout << Name << ": " << "You know that I always treat you like" << endl;
                         cout << "    my own sister." << endl;
                         cout << "-----------------------------------------------" << endl;
                         cout << "(0)You are going to save her? That is crazy!" << endl;
                         cout << "(1)I will go with you." << endl;
                         cout << "(SELECT)>>>";
                         cin >> temp2;
                         cout << "Muye: You know, 10 years ago?" << endl;
                         cout << "-----------------------------------------------" << endl;
                         cout << "(0)Are you taling about...." << endl;
                         cout << "(1)I know that day." << endl;
                         cout << "(SELECT)>>>";
                         cin >> temp3;
                         TimeMachine();
                         cout << Name << ": " << "So that is what are you talking" << endl;
                         cout << "   about." << endl;
                         cout << "Muye: Are you going to keep your promise?" << endl;
                         cout << "-----------------------------------------------" << endl;
                         cout << "(0)Really?" << endl;
                         cout << "(1)Do you mean?" << endl;
                         cout << "(SELECT)>>>";
                         cin >> temp5;
                         cout << "Muye: I gotta go, see you Shixiong." << endl;
                         cout << "-----------------------------------------------" << endl;
                         cout << "(0)Where are you going?" << endl;
                         cout << "(1)Bye." << endl;
                         cout << "(SELECT)>>>";
                         cin >> temp4;
                         if((temp1==0)&&(temp2==1)&&(temp3==1)&&(temp4==0))
                         Muye = true;
                         break;
                    default:
                           cout << "Error" << endl;
                           exit(1);
     }
}
